package com.rd.student.ruanjian.class1.duhang;

import java.util.ArrayList;
import java.util.LinkedList;

class Student{
    String name;
    String zhuanye;
    String miaoshu ;
    String age ;
    int class1;
    ArrayList arrayList = new ArrayList();
    Student s;

    //根据班级返回
    public Student returnOfage(int class1){
        for (int i = 0; i < arrayList.size(); i++) {
            s=(Student) arrayList.get(i);
            if(s.class1 == (class1)){
                s = (Student)arrayList.get(i);
                return s;
            }
        }
        return null;
    }
    //根据专业返回
    public Student returnOfzhuanye(String zhuanye){
        for (int i = 0; i < arrayList.size(); i++) {
            s=(Student) arrayList.get(i);
            if(s.zhuanye.equals(zhuanye)){
                s = (Student)arrayList.get(i);
                return s;
            }
        }
        return null;
    }
    //根据姓名返回
    public Student returnOfname(String name){
        for (int i = 0; i < arrayList.size(); i++) {
            s=(Student) arrayList.get(i);
            if(s.name.equals(name)){
                s = (Student)arrayList.get(i);
                return s;
            }
        }
        return null;
    }
    //根据年龄返回
    public Student returnOfage(String age){
        for (int i = 0; i < arrayList.size(); i++) {
            s=(Student) arrayList.get(i);
            if(s.age.equals(age)){
                s = (Student)arrayList.get(i);
                return s;
            }
        }
        return null;
    }
    //名字合ji
    public ArrayList getSumName (){ return arrayList; }
    public Student(String name, String zhuanye, int class1) {
        this.name = name;
        this.zhuanye = zhuanye;
        this.class1 = class1;
        arrayList.add(name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getZhuanye() {
        return zhuanye;
    }

    public void setZhuanye(String zhuanye) {
        this.zhuanye = zhuanye;
    }

    public int getClass1() {
        return class1;
    }

    public void setClass1(int class1) {
        this.class1 = class1;
    }

    @Override
    public String toString() {
        return "学生：" +
                "姓名：" + name + '\'' +
                ", 专业：" + zhuanye + '\'' +
                ", 班级：" + class1 ;
    }
}
